home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / mwheel / MWTEST4.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-08-15  |  5.2 KB  |  159 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "MouseWheel ActiveX Demonstration"
  4.    ClientHeight    =   7800
  5.    ClientLeft      =   3330
  6.    ClientTop       =   2010
  7.    ClientWidth     =   5595
  8.    Height          =   8205
  9.    Icon            =   "MWTest4.frx":0000
  10.    Left            =   3270
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   7800
  13.    ScaleWidth      =   5595
  14.    Top             =   1665
  15.    Width           =   5715
  16.    Begin VB.CheckBox Check1 
  17.       Caption         =   "Turn on Notifications"
  18.       Height          =   195
  19.       Left            =   180
  20.       TabIndex        =   0
  21.       Top             =   240
  22.       Width           =   2355
  23.    End
  24.    Begin VB.OptionButton Option1 
  25.       Caption         =   "ControlUnderMouse"
  26.       Height          =   195
  27.       Index           =   1
  28.       Left            =   2400
  29.       TabIndex        =   2
  30.       Top             =   600
  31.       Width           =   1875
  32.    End
  33.    Begin VB.OptionButton Option1 
  34.       Caption         =   "ControlWithFocus"
  35.       Height          =   195
  36.       Index           =   0
  37.       Left            =   180
  38.       TabIndex        =   1
  39.       Top             =   600
  40.       Width           =   1875
  41.    End
  42.    Begin VB.VScrollBar VScroll1 
  43.       Height          =   6795
  44.       LargeChange     =   50
  45.       Left            =   5220
  46.       Max             =   500
  47.       TabIndex        =   5
  48.       Top             =   900
  49.       Width           =   255
  50.    End
  51.    Begin VB.HScrollBar HScroll1 
  52.       Height          =   255
  53.       LargeChange     =   50
  54.       Left            =   180
  55.       Max             =   500
  56.       TabIndex        =   6
  57.       Top             =   7440
  58.       Width           =   4935
  59.    End
  60.    Begin VB.ListBox List1 
  61.       Height          =   3135
  62.       IntegralHeight  =   0   'False
  63.       Left            =   180
  64.       TabIndex        =   4
  65.       Top             =   4200
  66.       Width           =   4935
  67.    End
  68.    Begin VB.TextBox Text1 
  69.       Height          =   3135
  70.       Left            =   180
  71.       MultiLine       =   -1  'True
  72.       ScrollBars      =   3  'Both
  73.       TabIndex        =   3
  74.       Text            =   "MWTest4.frx":000C
  75.       Top             =   900
  76.       Width           =   4935
  77.    End
  78.    Begin MouseWheelOCX.MouseWheel MouseWheel1 
  79.       Left            =   4620
  80.       Top             =   180
  81.       _ExtentX        =   847
  82.       _ExtentY        =   847
  83.    End
  84. Attribute VB_Name = "Form1"
  85. Attribute VB_Creatable = False
  86. Attribute VB_Exposed = False
  87. Option Explicit
  88. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
  89. Private Sub MouseWheel1_AfterMouseWheel(ByVal hWnd As Long, ByVal Delta As Long, ByVal Shift As Long, ByVal Button As Long, ByVal x As Long, ByVal y As Long)
  90.    Select Case hWnd
  91.       Case Me.hWnd, Option1(0).hWnd, Option1(1).hWnd
  92.          If Option1(0).Value Then
  93.             Option1(1).Value = True
  94.          Else
  95.             Option1(0).Value = True
  96.          End If
  97.       Case Check1.hWnd
  98.          Check1.Value = Abs(Not CBool(Check1.Value))
  99.    End Select
  100. End Sub
  101. Private Sub MouseWheel1_BeforeMouseWheel(ByVal hWnd As Long, ByVal Delta As Long, ByVal Shift As Long, ByVal Button As Long, ByVal x As Long, ByVal y As Long, Cancel As Boolean)
  102.    'Debug.Print "MouseWheel hWnd: "; Hex(hWnd), "Delta:"; Delta, _
  103.                "Shift: "; Hex(Shift), "Button: "; Hex(Button), _
  104.                "X,Y: "; CStr(x); ","; CStr(y)
  105.    Call UpdateCaption
  106.    Select Case hWnd
  107.       Case Text1.hWnd
  108.          If Button = vbMiddleButton Then
  109.             Call MouseWheel1.HorzScroll(hWnd, Delta)
  110.             Cancel = True
  111.          End If
  112.    End Select
  113. End Sub
  114. Private Sub UpdateCaption()
  115.    ' Query for current number of scrolllines
  116.    MouseWheel1.Refresh
  117.    If MouseWheel1.ScrollLines = -1 Then
  118.       Me.Caption = "ScrollLines: WHEEL_PAGESCROLL"
  119.    Else
  120.       Me.Caption = "ScrollLines: " & MouseWheel1.ScrollLines
  121.    End If
  122. End Sub
  123. Private Sub Check1_Click()
  124.    ' Turn on notification for these windows.
  125.    ' Only required in WinNT.
  126.    MouseWheel1.hWndNotify(Text1.hWnd) = CBool(Check1.Value)
  127.    MouseWheel1.hWndNotify(List1.hWnd) = CBool(Check1.Value)
  128. End Sub
  129. Private Sub Form_Load()
  130.    Dim i As Long, p As String
  131.    Dim f As String
  132.    ' Show form so it looks like something's happening
  133.    Me.Move (Screen.Width - Me.ScaleWidth) / 2, (Screen.Height - Me.ScaleHeight) / 2
  134.    Me.Show
  135.    Me.Refresh
  136.    Me.MousePointer = vbHourglass
  137.    ' Fill text boxes with "stuff"
  138.    Open Environ("windir") & "\win.ini" For Binary As #1
  139.    Text1.Text = Input(LOF(1), 1)
  140.    Close #1
  141.    Text1.Refresh
  142.    ' Fill listbox with "stuff"
  143.    f = Dir(Environ("windir") & "\*.*")
  144.    Do While Len(f)
  145.       List1.AddItem f
  146.       f = Dir
  147.    Loop
  148.    List1.Refresh
  149.    ' Turn on mouse wheel notification, and caption
  150.    Call UpdateCaption
  151.    Check1.Value = vbChecked
  152.    Option1(0).Value = True
  153.    Me.MousePointer = vbDefault
  154. End Sub
  155. Private Sub Option1_Click(Index As Integer)
  156.    ' Toggle ScrollWhich property
  157.    MouseWheel1.ScrollWhich = Index
  158. End Sub
  159.